package com.yjs.ppjokedemo.adapter;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;

import com.yjs.ppjokedemo.bean.LikedItem;
import com.yjs.ppjokedemo.databinding.ItemFindLikedBinding;

public class LikedListAdapter extends ListAdapter<LikedItem,LikedListAdapter.LikedViewHolder> {

    private LikedInterface mLikedInterface;

    public LikedListAdapter(LikedInterface likedInterface){
        super(LikedItem.itemCallback);
        this.mLikedInterface = likedInterface;
    }

    @Override
    public LikedViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
        ItemFindLikedBinding itemFindLikedBinding = ItemFindLikedBinding.inflate(layoutInflater,parent,false);

        return new LikedViewHolder(itemFindLikedBinding);
    }

    @Override
    public void onBindViewHolder(@NonNull LikedViewHolder holder, int position) {
        holder.mItemFindLikedBinding.setLikeItem(getItem(position));

        holder.mItemFindLikedBinding.executePendingBindings();
    }

    class LikedViewHolder extends RecyclerView.ViewHolder{
        ItemFindLikedBinding mItemFindLikedBinding;

        public LikedViewHolder(ItemFindLikedBinding itemFindLikedBinding){
            super(itemFindLikedBinding.getRoot());
            this.mItemFindLikedBinding = itemFindLikedBinding;
        }
    }

    public interface LikedInterface{

    }
}
